﻿{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}


{block name="content"}
<div class="t-art" style="margin-bottom:10px;">
	<a href="/AcpProject/add_phase" class="btn btn-blue"><i class="gicon-plus white"></i>添加阶段</a>
</div>
<div class="tablesWrap">
	<!-- end tables-searchbox -->
	<table class="wxtables">
		<colgroup>
		<col width="10%">
		<col width="45%">
		<col width="15%">
		<col width="15%">
		</colgroup>
		<thead>
			<tr>
				<td>选择</td>
				<td>阶段名称</td>
				<td>排序</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody>
		{if $phase_list}
		{foreach from=$phase_list item=v key=k}
			<tr>
				<td><input type="checkbox" class="checkbox" value='{$v.type_id}' name="a[]"></td> 
				<td class="sort-name">{$v.type_name}</td>
				<td class="serial">{$v.serial}</td>
				<td>
					<a href="/AcpProject/edit_phase/phase_id/{$v.type_id}"  class="btn" title="修改"><i class="gicon-edit black"></i>修改</a> 
					<a href="javascript:void(0);" onclick='delPhase({$v.type_id})' class="btn" title="删除"><i class="gicon-trash black"></i>删除</a> 
				</td>
			</tr>
		{/foreach}
		{else}
			<tr>
				<td colspan="4" class="center">没有记录</td>
			</tr>
		{/if}
		</tbody>
	</table>

	<div class="tables-btmctrl clearfix">
		<div class="fl">  
			<a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>  
			<a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>  
			<a href="javascript:;" class="btn btn-blue" onclick="batch_delPhase()">删除</a>  
        </div>
		<div class="fr">
			<div class="paginate">
				{$show}
			</div>
			<!-- end paginate -->
		</div>
	</div>
</div>
{/block} 

{block name="js"}

<script type="text/javascript">
{literal}
function Select(){
	var sel=document.getElementsByName("a[]");
	for(var i=0;i<sel.length;i++){
		sel[i].checked=true;
	}
}
//取消全选
function Cancel(){
	var sel=document.getElementsByName("a[]");
	for(var i=0;i<sel.length;i++){
		sel[i].checked=false;
	}
}

function delPhase(_ids){
	$.jPops.confirm({
		title:"提示",
		content:'您确定要删除这条数据吗？',
		okBtnTxt:"确定",
		cancelBtnTxt:"取消",
		callback:function(r){
			if(r){
				$.ajax({
					url: '/AcpProject/del_phase',
					data: {ids: _ids},
					dataType: 'json',
					success: function(data){
						if(data == 'success'){
							alert('删除成功');
							location.reload();
						}else{
							alert('删除失败');
						}
					}
				});
			}
			return true;
		}
	});
}

function batch_delPhase()
{
	
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要执行这些操作吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 var ids = '';
				 var count = 0;
				 $('input[name="a[]"]:checked').each(function(){
					 count ++;
					 ids += $(this).val() + ',';
				 });

				 if (!count)
				 {
					 alert('对不起，请选择至少一项进行操作！');
					 return;
				 }

				 ids = ids.substr(0, ids.length - 1);

				 $.post('/AcpProject/del_phase', {"ids":ids}, function(data, textStatus) 
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，删除失败');
					}
				});
			 }  
			 return true;  
		 }
	 });
}
{/literal}
</script>
{/block} 

{block name="css"}
<link rel="stylesheet" href="/Public/Css/acp/AcpNotice/list_sort.css" type="text/css" />
{literal}
<style>
#jpops .fi-name{width:75px;}
#jpops .form-controls{margin-left:80px;}
.t-list{ float:left;}
</style>
{/literal}
{/block}
